<?php
namespace app\<app>\controller;
use app\<app>\config\<controller>\Lists as ThatLists;
use app\<app>\config\<controller>\Logic as ThatLogic;
use think\facade\Request;
use app\common\middleware\Auth;
use app\common\middleware\Power;
use app\common\middleware\Log;

class <ccontroller>
{
    protected $middleware = [Auth::class => [], Power::class => [], Log::class => []];
    /*列表模板*/
    public function Index()
    {
        return ViewTpl('<app>/<controller>/lists');
    }

    /*列表模板及数据*/
    public function Lists()
    {
        if (Request::isAjax() || Request::isPost()) {
            $ThatLists = new ThatLists();
            $data['rows'] =$ThatLists->Lists(input());
            $data['total'] =$ThatLists->Count(input());
            return BackCode($data);
        }
    }

    /*列表配置*/
    public function Tabs()
    {
        if (Request::isAjax() || Request::isPost()) {
            $ThatLists = new ThatLists();
            $data = $ThatLists->Tabs(input());
            return BackCode($data);
        }
    }

    /*明细*/
    public function Detail()
    {
        if (Request::isAjax() || Request::isPost()) {
            $ThatLogic = new ThatLogic();
            $data=$ThatLogic->Detail(input());
            return BackCode($data['data'], $data['code'], $data['msg']);
        }
        return ViewTpl('<app>/<controller>/form');
    }

    /*新增数据*/
    public function Add()
    {
        if (Request::isAjax() || Request::isPost()) {
            $ThatLogic = new ThatLogic();
            $data=$ThatLogic->Add(input());
            return BackCode($data['data'], $data['code'], $data['msg']);
        }
        return ViewTpl('<app>/<controller>/form');
    }

    /*修改数据*/
    public function Edit()
    {
        if (Request::isAjax() || Request::isPost()) {
            $ThatLogic = new ThatLogic();
            $data=$ThatLogic->Edit(input());
            return BackCode($data['data'], $data['code'], $data['msg']);
        }
        return ViewTpl('<app>/<controller>/form');
    }

    /*删除单条数据*/
    public function Delete()
    {
        if (Request::isAjax() || Request::isPost()) {
            $ThatLogic = new ThatLogic();
            $data= $ThatLogic->Delete(input());
            return BackCode($data['data'], $data['code'], $data['msg']);
        }
    }

    /*批量删除数据*/
    public function AllDelete()
    {
        if (Request::isAjax() || Request::isPost()) {
            $ThatLogic = new ThatLogic();
            $data= $ThatLogic->Delete(input());
            return BackCode($data['data'], $data['code'], $data['msg']);
        }
    }

    /*单个字段修改*/
    public function UpField()
    {
        if (Request::isAjax() || Request::isPost()) {
            $ThatLogic = new ThatLogic();
            $data= $ThatLogic->UpdateField(input());
            return BackCode($data['data'], $data['code'], $data['msg']);
        }
    }

    /*导入Excel数据*/
    public function InExcel()
    {
        if (Request::isAjax() || Request::isPost()) {
            $file = Request::file("file") ? : Request::file("edit");
            $ThatLists = new ThatLists();
            $data=$ThatLists->InExcel($file);
            return BackCode($data['data'], $data['code'], $data['msg']);
        }
    }

    /*导出Excel数据*/
    public function OutExcel()
    {
        $ThatLists = new ThatLists();
        $ThatLists->OutExcel(input());
    }

    /*下载Excel模板*/
    public function TemplateExcel()
    {
        $ThatLists = new ThatLists();
        $ThatLists->TemplateExcel();
    }


}